package com.devilvan.betrice.aiqicha.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.aiqicha.dto.AiqichaLegalDocDto;
import com.devilvan.betrice.aiqicha.po.AiqichaLegalDocPo;
import com.devilvan.betrice.aiqicha.service.AiqichaLegalDocService;
import com.devilvan.betrice.aiqicha.mapper.AiqichaLegalDocMapper;
import com.devilvan.betrice.aiqicha.repository.AiqichaLegalDocRepository;
import com.devilvan.betrice.util.UCopy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description 爱企查-裁决文书信息 业务逻辑类
* @date 2022-09-24
*/
@Service
public class AiqichaLegalDocServiceImpl extends ServiceImpl<AiqichaLegalDocMapper, AiqichaLegalDocPo> implements AiqichaLegalDocService {
    @Resource(name = "aiqichaLegalDocRepository")
    private AiqichaLegalDocRepository aiqichaLegalDocRepository;

    @Override
    public AiqichaLegalDocPo saveUpdate(AiqichaLegalDocDto aiqichaLegalDocDto) {
        AiqichaLegalDocPo aiqichaLegalDocPo = new AiqichaLegalDocPo();
        UCopy.fullCopy(aiqichaLegalDocDto, aiqichaLegalDocPo);
        return aiqichaLegalDocRepository.saveAndFlush(aiqichaLegalDocPo);
    }

    @Override
    public List<AiqichaLegalDocPo> saveUpdateBatch(List<AiqichaLegalDocDto> list) {
        List<AiqichaLegalDocPo> aiqichaLegalDocPoList = UCopy.fullCopyCollections(list, AiqichaLegalDocPo.class);
        return aiqichaLegalDocRepository.saveAllAndFlush(aiqichaLegalDocPoList);
    }
}
